package org.whb.user.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.whb.basic.util.AjaxResult;
import org.whb.user.dto.UserDto;
import org.whb.user.service.IUserService;

@RestController
@RequestMapping("/user")
public class PhoneRegisterController {

    @Autowired
    private IUserService userService;


    @PostMapping("/phone/register")
    public AjaxResult phoneRegister(@RequestBody UserDto dto){
        try {
            userService.phoneRegister(dto);
            return new AjaxResult();
        } catch (RuntimeException e){
            e.printStackTrace();
            return AjaxResult
                    .me()
                    .setSuccess(false)
                    .setMessage(e.getMessage());
        }catch (Exception e) {
            e.printStackTrace();
            return AjaxResult
                    .me()
                    .setSuccess(false)
                    .setMessage("服务器出错啦，请稍后再试！！！");
        }
    }

}
